import React, {
    Component,
} from 'react';
import {
    StyleSheet,
    Dimensions,
    Text,
    View,
    TouchableOpacity,
    ImageBackground,
    Image,
    Platform,
    TextInput
} from 'react-native';

export default class PublishCarTextInput extends Component {

    constructor(props) {
        super(props);
        this.state = {

        }
    };

    componentDidMount() {

    }


    render() {
        return (
            <View style={[styles.itemBox, {borderBottomWidth: this.props.hideSepline ? 0:0.3}]}>
                <View style={styles.itemLeftBox}>
                    <Text style={styles.itemTitleText}>
                        {this.props.name}
                        {
                            this.props.necessary ?
                            <Text style={{ color: '#FB3D3C' }}>*</Text>
                            :
                            null
                        }
                    </Text>
                </View>
                <View style={styles.itemRightBox}>
                    <TextInput
                        keyboardType={this.props.keyboardType}
                        autoCorrect={false}
                        returnKeyType='done'
                        autoCapitalize='characters'
                        style={styles.textInput}
                        editable={!this.props.disable}
                        placeholder={this.props.placeholder ? this.props.placeholder : ('请输入'+this.props.name)}
                        placeholderTextColor="#999999"
                        value={this.props.value}
                        onChangeText={this.changeText.bind(this)}
                    />
                    <Text style={styles.unitText}>{this.props.unit}</Text>
                </View>
            </View>
        )
    }

    //输入框内容输入
    changeText(val) {
        if (this.props.onChangeText) {
            this.props.onChangeText(val)
        }
    }

}

const styles = StyleSheet.create({
    itemBox: {
        width: '100%',
        height: 45,
        borderBottomColor: '#e4e4e4',
        borderBottomWidth: 0.3,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between'
    },
    itemLeftBox: {
        width: 92,
    },
    itemRightBox: {
        flex: 1,
        height: '100%',
        marginLeft: 4,
        flexDirection: 'row',
        justifyContent: 'flex-start',
        alignItems: 'center'
    },
    itemTitleText: {
        lineHeight: 19,
        fontSize: 14,
        color: '#222222'
    },
    textInput: {
        color: '#333333',
        fontSize: 14,
        flex: 1,
        height: '100%',
    },
    unitText: {
        fontSize: 14,
        color: '#222',
        marginLeft: 12
    }

})